package com.elitesland.org.repo;

import com.elitesland.org.entity.OrgBuDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface OrgBuRepo extends JpaRepository<OrgBuDO, Long>, QuerydslPredicateExecutor<OrgBuDO> {

    List<OrgBuDO> findAllByParentIdOrderBySortNo(Long parentId);

    Optional<OrgBuDO> findByCode(String code);

    List<OrgBuDO> findAllByOuIdAndIdIn(Long ouId, List<Long> buIds);

    List<OrgBuDO> findAllByPathLike(String pathLeft);

    List<OrgBuDO> findAllByIdIn(List<Long> ids);

    void deleteAllByPathLike(String path);
}
